package com.prs.crm.service.oa.impl;

import java.io.File;
import java.util.Collection;

import com.prs.crm.context.Attach;
import com.prs.crm.context.Constrains;
import com.prs.crm.context.FileUtil;
import com.prs.crm.context.ToolKits;
import com.prs.crm.dao.oa.AfficheDao;
import com.prs.crm.domain.oa.Affiche;
import com.prs.crm.service.impl.BaseServiceImpl;
import com.prs.crm.service.oa.AfficheService;

public class AfficheServiceImpl extends BaseServiceImpl<Affiche,AfficheDao> implements AfficheService{

	@Override
	public void saveAffiche(Affiche affiche, File file, String fileName) {
		// TODO Auto-generated method stub
		Attach attach = FileUtil.getInstance().saveFile(file, fileName, "", Constrains.UPLOAD_DIR_AFFICHE);
		if(attach.getSrc() != null) {
			affiche.setAttach(attach.getSrc());
		}
		this.getDao().save(affiche);
	}

	@Override
	public Collection<Affiche> getAllAffiche() {
		// TODO Auto-generated method stub
		
		return this.getDao().getAllAffiche();
	}

	@Override
	public Collection<Affiche> getAfficheByIds(Integer[] ids) {
		// TODO Auto-generated method stub
		return this.getDao().getAfficheByIds(ToolKits.convertToIntAry(ids));
	}

	@Override
	public Collection<Affiche> getAfficheByUserCount(int pageCount) {
		// TODO Auto-generated method stub
		return this.getDao().getAfficheByUserCount(pageCount);
	}

	@Override
	public Collection<Affiche> getActivitys() {
		// TODO Auto-generated method stub
		return this.getDao().getAffichesByType("活动");
	}

	@Override
	public Collection<Affiche> getAffiches() {
		// TODO Auto-generated method stub
		return this.getDao().getAffichesByType("公告");
	}

	@Override
	public Collection<Affiche> getNews() {
		// TODO Auto-generated method stub
		return this.getDao().getAffichesByType("新闻");
	}

}
